package distribuicaoDeProfessores;

/**
 *
 * @author Jaime
 */
public class CadastroDeDisciplina extends javax.swing.JPanel {

    /** Creates new form CadastroDeDisciplina */
    public CadastroDeDisciplina() {
        initComponents();
        disciplinas = new Disciplinas();
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        nomeDisciplina = new javax.swing.JTextField();
        botaoCadastrar = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        listaPeriodo = new javax.swing.JComboBox();

        setBackground(new java.awt.Color(255, 255, 153));
        setLayout(new java.awt.BorderLayout());

        jLabel1.setFont(new java.awt.Font("Script MT Bold", 0, 36));
        jLabel1.setForeground(new java.awt.Color(0, 204, 0));
        jLabel1.setText("Cadastro de Disciplina");
        add(jLabel1, java.awt.BorderLayout.PAGE_START);

        jScrollPane1.setBackground(new java.awt.Color(255, 255, 153));

        jPanel1.setBackground(new java.awt.Color(255, 255, 204));
        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        nomeDisciplina.setColumns(50);
        nomeDisciplina.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nomeDisciplinaActionPerformed(evt);
            }
        });

        botaoCadastrar.setBackground(new java.awt.Color(255, 255, 51));
        botaoCadastrar.setFont(new java.awt.Font("Times New Roman", 0, 14));
        botaoCadastrar.setText("Cadastrar");
        botaoCadastrar.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        botaoCadastrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoCadastrarActionPerformed(evt);
            }
        });

        jLabel2.setText("Nome:");

        jLabel3.setText("Periodo: ");

        listaPeriodo.setBackground(new java.awt.Color(255, 255, 102));
        listaPeriodo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1º", "2º", "3º", "4º", "5º", "6º", "7º", "8º" }));
        listaPeriodo.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(33, 33, 33)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(nomeDisciplina, 0, 0, Short.MAX_VALUE)
                            .addComponent(listaPeriodo, 0, 99, Short.MAX_VALUE))
                        .addGap(183, 183, 183))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(botaoCadastrar, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(122, 122, 122))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(39, 39, 39)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(nomeDisciplina, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(listaPeriodo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 103, Short.MAX_VALUE)
                .addComponent(botaoCadastrar, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(40, 40, 40))
        );

        jScrollPane1.setViewportView(jPanel1);

        add(jScrollPane1, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents

    private void botaoCadastrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoCadastrarActionPerformed
        // Botão cadastrar
        Disciplina disciplina = new Disciplina(disciplinas.getAndIncrementCont(), nomeDisciplina.getText(), listaPeriodo.getSelectedIndex()+1);
        disciplinas.addDisciplina(disciplina);
        nomeDisciplina.setText("");
        javax.swing.JOptionPane.showMessageDialog(null, disciplina);
    }//GEN-LAST:event_botaoCadastrarActionPerformed

    private void nomeDisciplinaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nomeDisciplinaActionPerformed
        // Evento da caixa de texto nomeDisciplina
        Disciplina disciplina = new Disciplina(disciplinas.getAndIncrementCont(), nomeDisciplina.getText(), listaPeriodo.getSelectedIndex()+1);
        disciplinas.addDisciplina(disciplina);
        nomeDisciplina.setText("");
        javax.swing.JOptionPane.showMessageDialog(null, disciplina);
    }//GEN-LAST:event_nomeDisciplinaActionPerformed

    public Disciplinas getDisciplinas() {
        return disciplinas;
    }

    public void setDisciplinas(Disciplinas disciplinas) {
        this.disciplinas = disciplinas;
    }
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoCadastrar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JComboBox listaPeriodo;
    private javax.swing.JTextField nomeDisciplina;
    // End of variables declaration//GEN-END:variables
    Disciplinas disciplinas;
}
